package com.seavenois.alife2;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Window;
import android.widget.Toast;

/*************************************************/
/* The Game activity *****************************/
/*************************************************/
/* Works for both Heaven and Hell. ***************/
/* Controls all the game flow. Check in-code *****/
/* comments. *************************************/
/*************************************************/
public class Game extends Activity implements OnGestureListener{
	
	//Preferences and cheats variables
	boolean prefFX, prefMusic, prefFullScreen, prefKeepAwake;
	boolean cheatX10, cheatDebt, cheatEarnings;
	
	//Global variables - System
	private byte scenario;	//Are we playing in Hell or in Heaven?
	private int speed;		//The speed of the time flow
	CountDownTimer timer;	//Timer to control the time flow
	GameView gameView;		//Custom View with the scenario
	GestureDetector gestureScanner;	//Controls tapping, dragging...
	MediaPlayer specialPlayer;
	FragmentManager fragmentManager = getFragmentManager();
	DialogReport reportFragment = new DialogReport();
	boolean viewReport = false;
	boolean game = true; //Indicates if the game is running
	
	//Global variables - Game
	private int money = 0;			//Current money
	private int year = 0;			//Current year
	private int souls = 0;			//Numbers of souls in player's Hell or Heaven
	private int lostSouls = 0;		//Souls lost on the current year
	private int lostInHosting = 0;	//Souls lost on the current year in the hosting stage
	private int lostInFormation = 0;	//Souls lost on the current year in the hosting stage
	private int lostInReincarnation = 0;	//Souls lost on the current year in the hosting stage
	private Soul[] soul = new Soul[1000000];//Array for souls
	private int earnings = 0;		//Money earned on the current year
	private float soulRate = Values.INITIAL_SOUL_RATE; //How much am I paid per soul. TODO: Varies along game
	private int inputCapacity = 0;	//Number of souls that doors allow to enter each year
	private int input = 0;			//Number of souls willing to enter each year
	private int trainingCapacity = 0;//Places available in academy
	private int students = 0;		//Souls being trained to be workers
	private int workersLocal = 0;	//Local workers
	private int workersNeeded = 0;	//Needed workers
	private int workersExternal = 0;//External workers (workersNeeded - workersLocal)
	private int workersUnemployed = 0;//Unemployed workers (workersLocal - workersNeeded)
	private int workersCommuting = 0;//Commuting workers (workersLocal - beds)
	private int workersResident = 0;//Resident workers (workersLocal - workersCommuting)
	private int beds = 0;			//How many workers can live here
	private int cars = 0;			//How many reincarnations/years I can handle
	private int carsNeeded = 0;		//How many reincarnations are required each year
	private int reincarnations = 0; 	//How many reincarnation are actually done each year
	private int energyProduction = 0;//Energy produced by siphons
	private int energyNeeded = 0;	//Energy required to work
	private int energyExternal = 0;	//Imported energy (energyNeeded - energyProduction)
	private int[] hostingCapacity = {0, 0, 0, 0, 0, 0, 0}; //How many souls of each type can I host
	private int[] hostingDemand = {0, 0, 0, 0, 0, 0, 0}; //How many souls of each type looking for a place
	private int[] buildingCapacity = {0, 0, 0, 0}; //How many of its specific attribute has each type of building 
	private int[] buildingDemand = {0, 0, 0, 0}; //In order: Doors, Academys, Topias, Stations
	//Info about benefits and losses to be passed to the report activity. It will contain, in order:
	//input, lostSouls, lostInHsoting, lostInFormation, lostInReincarnation, reincarnations, workersNeeded + workersUnemployed,
	//workersLocal, workersResident, workersCommuting, workersExternal, workersUnemployed, energyNeeded, energyProduction, energyExternal
	private int[] reportInfo = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	private int specialLevel = 0;	//Level of the last special building built	
	

	//Controls the time flow speed and clocks the years flow
	public void changeSpeed(int time){
		timer = new CountDownTimer(150000, time) {
			public void onTick(long millisUntilFinished) {
				year ++;
				newYear();
			}
			public void onFinish() {
				year++;
				newYear();
				start();
			}
		}.start();
	}
	
	
	//Lot of things done here. See the in-code comments
	@Override
	@SuppressWarnings("deprecation")
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		   
		//Get scenario
		Intent intent = getIntent();
		if ((Boolean) intent.getExtras().get("heaven") )
			scenario = Values.SCENARIO_HEAVEN;
		else
			scenario = Values.SCENARIO_HELL;
		   
	   //Gesture detectors are deprecated.
	   //But I have no idea how to implement this in other way
	   gestureScanner = new GestureDetector(this);
	
	   //Load preferences and cheats
	   loadPreferences();
	   loadCheats();
	   
	   //Configure the game window
	   //TODO: keep awake if flagged in preferences
	   requestWindowFeature(Window.FEATURE_NO_TITLE);
	   gameView = new GameView(this, scenario);
	   setContentView(gameView);
	   
	   //Assign initial values
	   money = Values.INITIAL_MONEY;
	   year = 0;
	   souls = 0;
	   speed = Values.TIME_NORMAL; //TODO: Initially set to TIME_SLOW
	   
	   //Load game if necessary
	   if ((Boolean) intent.getExtras().get("load"))
		   loadGame();
	   
	   //Start time flow
	   changeSpeed(speed);
	}

	//Notice the gameView about the new year, so it can update some values
	public void newYear(){
		if (game == false)
			return;
		gameView.updateMsg(year, money, souls);
		gameView.invalidate();
		//Set values to 0
		for (int i = 0; i < 7; i ++)
			hostingCapacity[i] = 0;
		//For each box
		for (int i = 0; i < 144; i ++){
			//Age boxes
			gameView.box[i].newYear();
			//Calculate vibes (each 5 years)
			if (year % 5 == 0)
				calculateVibes();
			//Update areas
			//First update only changes the graphic, so there is no need to call build() here
			if (gameView.box[i].getAge() == Values.AGE_1){
				switch (gameView.box[i].getBuilding()){
					case Values.BUILDING_MAROON_1:
						gameView.build(i, Values.BUILDING_MAROON_1, true);
						play(R.raw.click);
						break;
					case Values.BUILDING_PINK_1:
						gameView.build(i, Values.BUILDING_PINK_1, true);
						play(R.raw.click);
						break;
					case Values.BUILDING_YELLOW_1:
						gameView.build(i, Values.BUILDING_YELLOW_1, true);
						play(R.raw.click);
						break;
					case Values.BUILDING_BLUE_1:
						gameView.build(i, Values.BUILDING_BLUE_1, true);
						play(R.raw.click);
						break;
					case Values.BUILDING_RED_1:
						gameView.build(i, Values.BUILDING_RED_1, true);
						play(R.raw.click);
						break;
					case Values.BUILDING_PURPLE_1:
						gameView.build(i, Values.BUILDING_PURPLE_1, true);
						play(R.raw.click);
						break;
					case Values.BUILDING_GREEN_1:
						gameView.build(i, Values.BUILDING_GREEN_1, true);
						play(R.raw.click);
						break;
				}
			}
			//Upgrade areas to level 2
			if (gameView.box[i].getAge() == Values.AGE_2){
				switch (gameView.box[i].getBuilding()){
					case Values.BUILDING_MAROON_1:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_MAROON_2_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_MAROON_2_GOOD);
							else
								build(i, Values.BUILDING_MAROON_2_NEUTRAL);
						}
						break;
					case Values.BUILDING_PINK_1:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_PINK_2_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_PINK_2_GOOD);
							else
								build(i, Values.BUILDING_PINK_2_NEUTRAL);
						}
						break;
					case Values.BUILDING_YELLOW_1:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_YELLOW_2_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_YELLOW_2_GOOD);
							else
								build(i, Values.BUILDING_YELLOW_2_NEUTRAL);
						}
						break;
					case Values.BUILDING_BLUE_1:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_BLUE_2_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_BLUE_2_GOOD);
							else
								build(i, Values.BUILDING_BLUE_2_NEUTRAL);
						}
						break;
					case Values.BUILDING_RED_1:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_RED_2_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_RED_2_GOOD);
							else
								build(i, Values.BUILDING_RED_2_NEUTRAL);
						}
						break;
					case Values.BUILDING_GREEN_1:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_GREEN_2_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_GREEN_2_GOOD);
							else
								build(i, Values.BUILDING_GREEN_2_NEUTRAL);
						}
						break;
					case Values.BUILDING_PURPLE_1:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_PURPLE_2_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_PURPLE_2_GOOD);
							else
								build(i, Values.BUILDING_PURPLE_2_NEUTRAL);
						}
						break;
				}
			}
			if (gameView.box[i].getAge() == Values.AGE_3){
				switch (gameView.box[i].getBuilding()){
					case Values.BUILDING_MAROON_2_BAD:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_MAROON_3_BAD);
						else
							build(i, Values.BUILDING_MAROON_3_NEUTRAL);
						break;
					case Values.BUILDING_MAROON_2_NEUTRAL:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_MAROON_3_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_MAROON_3_GOOD);
							else
								build(i, Values.BUILDING_MAROON_3_NEUTRAL);
						}
						break;
					case Values.BUILDING_MAROON_2_GOOD:
						if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
							build(i, Values.BUILDING_MAROON_3_GOOD);
						else
							build(i, Values.BUILDING_MAROON_3_NEUTRAL);
						break;
					case Values.BUILDING_PINK_2_BAD:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_PINK_3_BAD);
						else
							build(i, Values.BUILDING_PINK_3_NEUTRAL);
						break;
					case Values.BUILDING_PINK_2_NEUTRAL:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_PINK_3_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_PINK_3_GOOD);
							else
								build(i, Values.BUILDING_PINK_3_NEUTRAL);
						}
						break;
					case Values.BUILDING_PINK_2_GOOD:
						if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
							build(i, Values.BUILDING_PINK_3_GOOD);
						else
							build(i, Values.BUILDING_PINK_3_NEUTRAL);
						break;
					case Values.BUILDING_YELLOW_2_BAD:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_YELLOW_3_BAD);
						else
							build(i, Values.BUILDING_YELLOW_3_NEUTRAL);
						break;
					case Values.BUILDING_YELLOW_2_NEUTRAL:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_YELLOW_3_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_YELLOW_3_GOOD);
							else
								build(i, Values.BUILDING_YELLOW_3_NEUTRAL);
						}
						break;
					case Values.BUILDING_YELLOW_2_GOOD:
						if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
							build(i, Values.BUILDING_YELLOW_3_GOOD);
						else
							build(i, Values.BUILDING_YELLOW_3_NEUTRAL);
						break;
					case Values.BUILDING_BLUE_2_BAD:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_BLUE_3_BAD);
						else
							build(i, Values.BUILDING_BLUE_3_NEUTRAL);
						break;
					case Values.BUILDING_BLUE_2_NEUTRAL:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_BLUE_3_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_BLUE_3_GOOD);
							else
								build(i, Values.BUILDING_BLUE_3_NEUTRAL);
						}
						break;
					case Values.BUILDING_BLUE_2_GOOD:
						if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
							build(i, Values.BUILDING_BLUE_3_GOOD);
						else
							build(i, Values.BUILDING_BLUE_3_NEUTRAL);
						break;
					case Values.BUILDING_RED_2_BAD:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_RED_3_BAD);
						else
							build(i, Values.BUILDING_RED_3_NEUTRAL);
						break;
					case Values.BUILDING_RED_2_NEUTRAL:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_RED_3_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_RED_3_GOOD);
							else
								build(i, Values.BUILDING_RED_3_NEUTRAL);
						}
						break;
					case Values.BUILDING_RED_2_GOOD:
						if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
							build(i, Values.BUILDING_RED_3_GOOD);
						else
							build(i, Values.BUILDING_RED_3_NEUTRAL);
						break;
					case Values.BUILDING_GREEN_2_BAD:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_GREEN_3_BAD);
						else
							build(i, Values.BUILDING_GREEN_3_NEUTRAL);
						break;
					case Values.BUILDING_GREEN_2_NEUTRAL:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_GREEN_3_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_GREEN_3_GOOD);
							else
								build(i, Values.BUILDING_GREEN_3_NEUTRAL);
						}
						break;
					case Values.BUILDING_GREEN_2_GOOD:
						if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
							build(i, Values.BUILDING_GREEN_3_GOOD);
						else
							build(i, Values.BUILDING_GREEN_3_NEUTRAL);
						break;
					case Values.BUILDING_PURPLE_2_BAD:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_PURPLE_3_BAD);
						else
							build(i, Values.BUILDING_PURPLE_3_NEUTRAL);
						break;
					case Values.BUILDING_PURPLE_2_NEUTRAL:
						if (gameView.box[i].getUnderVibes() < Values.VIBES_BAD)
							build(i, Values.BUILDING_PURPLE_3_BAD);
						else{
							if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
								build(i, Values.BUILDING_PURPLE_3_GOOD);
							else
								build(i, Values.BUILDING_PURPLE_3_NEUTRAL);
						}
						break;
					case Values.BUILDING_PURPLE_2_GOOD:
						if (gameView.box[i].getUnderVibes() > Values.VIBES_GOOD)
							build(i, Values.BUILDING_PURPLE_3_GOOD);
						else
							build(i, Values.BUILDING_PURPLE_3_NEUTRAL);
						break;
				}
			}
		}
		//Calculate parameters
		for (int j = 0; j < 7; j ++)
			hostingCapacity[j] = 0;
		inputCapacity = 0;
		lostSouls = 0;
		lostInHosting = 0;
		lostInFormation = 0;
		lostInReincarnation = 0;
		reincarnations = 0;
		workersNeeded = 0;
		beds = 0;
		energyNeeded = 0;
		energyProduction = 0;
		cars = 0;
		trainingCapacity = 0;
		for (int i = 0; i < 144; i ++){
			//Add hosting
			for (int j = 0; j < 7; j ++)
				hostingCapacity[j] += gameView.box[i].getHosting(j);
			//Add workers
			workersNeeded += gameView.box[i].getWorkplaces();
			//Add input capacity
			inputCapacity += gameView.box[i].getInputCapacity();
			//Add beds
			beds += gameView.box[i].getBeds();
			//Add energy consumption
			energyNeeded += gameView.box[i].getConsumption();
			//Add energy production
			energyProduction += gameView.box[i].getProduction();
			//Add reincarnation cars
			cars += gameView.box[i].getCars();
			//Add worker training capacity
			inputCapacity += gameView.box[i].getInputCapacity();
			//Add trainingCapacity
			trainingCapacity += gameView.box[i].getStudyplaces();
		}
		//Calculate other data
		workersCommuting = workersLocal - beds;
		if (workersCommuting < 0)
			workersCommuting = 0;
		workersResident = workersLocal - workersCommuting;
		workersUnemployed = workersLocal - workersNeeded;
		if (workersUnemployed < 0)
			workersUnemployed = 0;
		workersExternal = workersNeeded - workersLocal;
		if (workersExternal < 0)
			workersExternal = 0;
		energyExternal = energyNeeded - energyProduction;
		if (energyExternal < 0)
			energyExternal = 0;
		//Calculate the soul input flow
		input = (int)(0.1 * year + input * (Math.random() * 0.4));
		if (input < 0)
			input = 0;
		if (input > inputCapacity)
			input = inputCapacity;
		//Reset year earnings
		earnings = 0;
		lostSouls = 0;
		//Add new souls to souls array
		int i = 0, placed = 0;
		while (placed < input){
			if (soul[i] == null){
				soul[i] = null;
				soul[i] = new Soul();
				placed ++;
			}
			else{
				if (soul[i].isWorker()){
					soul[i] = null;
					soul[i] = new Soul();
					placed ++;
				}
			}
			i ++;
		}
		//Calculate hosting demand
		for (i = 0; i < 7; i ++)
			hostingDemand[i] = 0;
		for (i = 0; i < 1000000; i ++){ //TODO: Find out last populated position
			if (soul[i] != null)
				if (soul[i].getColor() != Values.COLOR_NONE){
					hostingDemand[soul[i].getColor() - 1] ++;
				}
		}
		//Calculate lost souls in hosting stage
		for (i = 0; i < 7; i ++)
			if (hostingCapacity[i] < hostingDemand[i]){
				lostInHosting += hostingDemand[i] - hostingCapacity[i];
				hostingDemand[i] = hostingCapacity[i];
			}
		//TODO: Count lostInFormation and lostInReincarnation
		lostSouls = lostInHosting + lostInFormation + lostInReincarnation;
		souls += input;
		earnings += input * soulRate;
		earnings -= Values.LOOS_HOSTING * lostInHosting;
		//Add earnings to money
		money += earnings;
		//Update fragment dialog
		if (viewReport == true){
			buildingCapacity[0] = inputCapacity;
			buildingCapacity[1] = trainingCapacity;
			buildingCapacity[2] = beds;
			buildingCapacity[3] = cars;
			buildingDemand[0] = input;
			buildingDemand[1] = students;
			buildingDemand[2] = workersLocal;
			buildingDemand[3] = carsNeeded;
			//Info about benefits and losses to be passed to the report activity. It will contain, in order:
			//input, lostSouls, lostInHsoting, lostInFormation, lostInReincarnation, reincarnations, workersNeeded + workersUnemployed,
			//workersLocal, workersResident, workersCommuting, workersExternal, workersUnemployed, energyNeeded, energyProduction, energyExternal
			reportInfo[0] = input;
			reportInfo[1] = lostSouls;
			reportInfo[2] = lostInHosting;
			reportInfo[3] = lostInFormation;
			reportInfo[4] = lostInReincarnation;
			reportInfo[5] = reincarnations;
			reportInfo[6] = workersNeeded + workersUnemployed;
			reportInfo[7] = workersLocal;
			reportInfo[8] = workersResident;
			reportInfo[9] = workersCommuting;
			reportInfo[10] = workersExternal;
			reportInfo[11] = workersUnemployed;
			reportInfo[12] = energyNeeded;
			reportInfo[13] = energyProduction;
			reportInfo[14] = energyExternal;
			reportFragment.updateData(scenario, gameView.getScreenDimensions()[0], hostingDemand, hostingCapacity, buildingDemand, buildingCapacity, reportInfo, soulRate);
		}
		//Special buildings?
		if (souls > Values.SPECIAL_1_SOULS && specialLevel == 0){
			playSpecial(false);
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			AlertDialog alert;
			switch (scenario){
				case Values.SCENARIO_HEAVEN:
					builder.setTitle(R.string.heavenSpecial1);
					builder.setIcon(R.drawable.icon_special_1_heaven);
					builder.setMessage(getString(R.string.heavenSpecial1Presentation, Values.SPECIAL_1_SOULS));
					break;
				case Values.SCENARIO_HELL:
					builder.setTitle(R.string.hellSpecial1);
					builder.setIcon(R.drawable.icon_special_1_hell);
					builder.setMessage(getString(R.string.hellSpecial1Presentation, Values.SPECIAL_1_SOULS));
					break;
			}
			builder.setNegativeButton(getString(R.string.thanks), new DialogInterface.OnClickListener(){
				public void onClick(DialogInterface dialog, int id){
					playSpecial(true);
				}
			});	
	        alert = builder.create();
	        alert.show();
			i = findRandomBox();
			build(i, Values.BUILDING_SPECIAL_1);
			specialLevel = 1;
		}
		if (souls > Values.SPECIAL_2_SOULS && specialLevel == 1){
			playSpecial(false);
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			AlertDialog alert;
			switch (scenario){
				case Values.SCENARIO_HEAVEN:
					builder.setTitle(R.string.heavenSpecial2);
					builder.setIcon(R.drawable.icon_special_2_heaven);
					builder.setMessage(getString(R.string.heavenSpecial2Presentation, Values.SPECIAL_2_SOULS));
					break;
				case Values.SCENARIO_HELL:
					builder.setTitle(R.string.hellSpecial2);
					builder.setIcon(R.drawable.icon_special_2_hell);
					builder.setMessage(getString(R.string.hellSpecial2Presentation, Values.SPECIAL_2_SOULS));
					break;
			}
			builder.setNegativeButton(getString(R.string.thanks), new DialogInterface.OnClickListener(){
				public void onClick(DialogInterface dialog, int id){
					playSpecial(true);
				}
			});	
	        alert = builder.create();
	        alert.show();
			i = findRandomBox();
			build(i, Values.BUILDING_SPECIAL_2);
			specialLevel = 2;
		}
		if (souls > Values.SPECIAL_2_SOULS && specialLevel == 2){
			playSpecial(false);
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			AlertDialog alert;
			switch (scenario){
				case Values.SCENARIO_HEAVEN:
					builder.setTitle(R.string.heavenSpecial3);
					builder.setIcon(R.drawable.icon_special_3_heaven);
					builder.setMessage(getString(R.string.heavenSpecial3Presentation, Values.SPECIAL_3_SOULS));
					break;
				case Values.SCENARIO_HELL:
					builder.setTitle(R.string.hellSpecial3);
					builder.setIcon(R.drawable.icon_special_3_hell);
					builder.setMessage(getString(R.string.hellSpecial3Presentation, Values.SPECIAL_3_SOULS));
					break;
			}
			builder.setNegativeButton(getString(R.string.thanks), new DialogInterface.OnClickListener(){
				public void onClick(DialogInterface dialog, int id){
					playSpecial(true);
				}
			});	
	        alert = builder.create();
	        alert.show();
			i = findRandomBox();
			build(i, Values.BUILDING_SPECIAL_3);
			specialLevel = 3;
		}
		//Each six years, save automatically
		if (year % 6 == 0)
			saveGame();
	}
	
	//Returns an empty, non river, random box
	public int findRandomBox(){
		int max = 0, rnd;
		int[] free = new int[144];
		for (int i = 0; i < 144; i ++){
			if (gameView.box[i].getBuilding() == Values.BUILDING_NONE && gameView.box[i].isRiver() == false){
				free[max] = i;
				max ++;
			}
		}
		rnd = (int)(Math.random() * (max + 1));
		return free[rnd];
	}
	
	//Reads touch events
	@Override
	public boolean onTouchEvent(MotionEvent me){
		return gestureScanner.onTouchEvent(me);
	}

	//When scrolling the board, gameView must be noticed
	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)	{
		gameView.handleScroll(distanceX,distanceY);
		return true;
	}

	//Not used, but must me here
	@Override
	public boolean onDown(MotionEvent e){
		return true;
	}

	//Not used, but must me here
	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){
		return true;
	}

	//Not used, but must me here
	@Override
	public void onLongPress(MotionEvent e){    }

	//Not used, but must me here
	@Override
	public void onShowPress(MotionEvent e) {   }    

	//Run when the board is tapped
	@Override
	public boolean onSingleTapUp(MotionEvent e){
		//Get coordinates of the touch event
		int x = (int) e.getX();
		int y = (int) e.getY();
		//Has the low pannel been touched?
		if (y > gameView.getScreenDimensions()[1] - Values.LOW_PANEL_HEIGHT){
			if (x < gameView.getScreenDimensions()[0] * Values.LOW_PANEL_DIVIDER_1)
				Toast.makeText(getApplicationContext(), "YEAR PANNEL", Toast.LENGTH_SHORT).show();
			if (x >= gameView.getScreenDimensions()[0] * Values.LOW_PANEL_DIVIDER_1 && x < gameView.getScreenDimensions()[0] * Values.LOW_PANEL_DIVIDER_2)
				Toast.makeText(getApplicationContext(), "MONEY PANEL", Toast.LENGTH_SHORT).show();
			if (x >= gameView.getScreenDimensions()[0] * Values.LOW_PANEL_DIVIDER_2 && x < gameView.getScreenDimensions()[0] * Values.LOW_PANEL_DIVIDER_3)
				Toast.makeText(getApplicationContext(), "SOUL PANEL", Toast.LENGTH_SHORT).show();
			if (x >= gameView.getScreenDimensions()[0] * Values.LOW_PANEL_DIVIDER_3){
				//Load the fragment
				viewReport = true;
				fragmentManager = getFragmentManager();
				reportFragment = new DialogReport();
			    reportFragment.show(fragmentManager, "report" + Integer.toString(year));
			}
			return true;
		}
		
		//Find out in which box (if any) happened the tap event
		int b = gameView.locateTouch(x, y);
		//Show info about the tapped box
		if (b != -1)
			showInfo(b);
		return true;
	}

	//Shows a dialog with info about the tapped box
	//It changes depending on the box properties
	public void showInfo(int box){
		//Load the fragment
		FragmentManager fragmentManager = getFragmentManager();
		DialogInfo newFragment = new DialogInfo();
		//Set initial values
	    String title = "", description = "", upgradeText = "", emitting = "", under="";
	    //Values that will determine the sections of the dialog that will be shown
	    boolean river = true, buildable = true, destroyable = true, upgradeable = true, parametrizable = true;
	    int icon = R.drawable.ic_launcher;
	    int upgradeIcon = R.drawable.ic_launcher;
	    int nextBuilding = -1;
	    int value = 0, maxValue = 0;
	    String barTitle = "BAR", barText = "TEXT";
	    //Find out vibes strings
	    switch (scenario){
	    	case Values.SCENARIO_HEAVEN:
			    if (gameView.box[box].getUnderVibes() >= Values.VIBES_GOOD && gameView.box[box].getUnderVibes() < Values.VIBES_AMAZING)
					under = "\n\n" + getString(R.string.underGoodVibes);
				else if (gameView.box[box].getUnderVibes() >= Values.VIBES_AMAZING && gameView.box[box].getUnderVibes() < Values.VIBES_DIVINE)
					under = "\n\n" + getString(R.string.underAmazingVibes);
				else if (gameView.box[box].getUnderVibes() >= Values.VIBES_DIVINE)
					under = "\n\n" + getString(R.string.underDivineVibes);
				else if (gameView.box[box].getUnderVibes() <= Values.VIBES_BAD && gameView.box[box].getUnderVibes() > Values.VIBES_HORRIBLE)
					under = "\n\n" + getString(R.string.underBadVibes);
				else if (gameView.box[box].getUnderVibes() <= Values.VIBES_HORRIBLE && gameView.box[box].getUnderVibes() > Values.VIBES_CHAOTIC)
					under = "\n\n" + getString(R.string.underHorribleVibes);
				else if (gameView.box[box].getUnderVibes() <= Values.VIBES_CHAOTIC)
					emitting = "\n\n" + getString(R.string.emittingChaoticVibes);
			    if (gameView.box[box].getVibes() >= Values.VIBES_GOOD && gameView.box[box].getVibes() < Values.VIBES_AMAZING)
					emitting = "\n\n" + getString(R.string.emittingGoodVibes);
				else if (gameView.box[box].getVibes() >= Values.VIBES_AMAZING && gameView.box[box].getVibes() < Values.VIBES_DIVINE)
					emitting = "\n\n" + getString(R.string.emittingAmazingVibes);
				else if (gameView.box[box].getVibes() >= Values.VIBES_DIVINE)
					emitting = "\n\n" + getString(R.string.emittingDivineVibes);
				else if (gameView.box[box].getVibes() <= Values.VIBES_BAD && gameView.box[box].getVibes() > Values.VIBES_HORRIBLE)
					emitting = "\n\n" + getString(R.string.emittingBadVibes);
				else if (gameView.box[box].getVibes() <= Values.VIBES_HORRIBLE && gameView.box[box].getVibes() > Values.VIBES_CHAOTIC)
					emitting = "\n\n" + getString(R.string.emittingHorribleVibes);
				else if (gameView.box[box].getVibes() <= Values.VIBES_CHAOTIC)
					emitting = "\n\n" + getString(R.string.emittingChaoticVibes);
			    break;
	    	case Values.SCENARIO_HELL:
			    if (gameView.box[box].getUnderVibes() >= Values.VIBES_GOOD && gameView.box[box].getUnderVibes() < Values.VIBES_AMAZING)
					under = "\n\n" + getString(R.string.underBadVibes);
				else if (gameView.box[box].getUnderVibes() >= Values.VIBES_AMAZING && gameView.box[box].getUnderVibes() < Values.VIBES_DIVINE)
					under = "\n\n" + getString(R.string.underHorribleVibes);
				else if (gameView.box[box].getUnderVibes() >= Values.VIBES_DIVINE)
					under = "\n\n" + getString(R.string.underChaoticVibes);
				else if (gameView.box[box].getUnderVibes() <= Values.VIBES_BAD && gameView.box[box].getUnderVibes() > Values.VIBES_HORRIBLE)
					under = "\n\n" + getString(R.string.underGoodVibes);
				else if (gameView.box[box].getUnderVibes() <= Values.VIBES_HORRIBLE && gameView.box[box].getUnderVibes() > Values.VIBES_CHAOTIC)
					under = "\n\n" + getString(R.string.underAmazingVibes);
				else if (gameView.box[box].getUnderVibes() <= Values.VIBES_CHAOTIC)
					under = "\n\n" + getString(R.string.underDivineVibes);
			    if (gameView.box[box].getVibes() >= Values.VIBES_GOOD && gameView.box[box].getVibes() < Values.VIBES_AMAZING)
					emitting = "\n\n" + getString(R.string.emittingBadVibes);
				else if (gameView.box[box].getVibes() >= Values.VIBES_AMAZING && gameView.box[box].getVibes() < Values.VIBES_DIVINE)
					emitting = "\n\n" + getString(R.string.emittingHorribleVibes);
				else if (gameView.box[box].getVibes() >= Values.VIBES_DIVINE)
					emitting = "\n\n" + getString(R.string.emittingChaoticVibes);
				else if (gameView.box[box].getVibes() <= Values.VIBES_BAD && gameView.box[box].getVibes() > Values.VIBES_HORRIBLE)
					emitting = "\n\n" + getString(R.string.emittingGoodVibes);
				else if (gameView.box[box].getVibes() <= Values.VIBES_HORRIBLE && gameView.box[box].getVibes() > Values.VIBES_CHAOTIC)
					emitting = "\n\n" + getString(R.string.emittingAmazingVibes);
				else if (gameView.box[box].getVibes() <= Values.VIBES_CHAOTIC)
					emitting = "\n\n" + getString(R.string.emittingDivineVibes);
			    break;
	    }
	    //Switch the building in the tapped box
	    switch (gameView.box[box].getBuilding()){
	    	//Empty box
	    	case Values.BUILDING_NONE:
	    		//With river
	    		if (gameView.box[box].isRiver()){
	    			switch (scenario){
	    				case Values.SCENARIO_HEAVEN:
	    					description = getString(R.string.dialogDescriptionHeavenRiver);
	    					title = getString(R.string.dialogTitleHeavenRiver);
	    					icon = R.drawable.icon_river_heaven;
	    					break;
	    				case Values.SCENARIO_HELL:
	    					description = getString(R.string.dialogDescriptionHellRiver);
	    					title = getString(R.string.dialogTitleHellRiver);
	    					icon = R.drawable.icon_river_hell;
	    					break;
	    			}
	    		}
	    		//Standard box
	    		else{
	    			switch (scenario){
	    				case Values.SCENARIO_HEAVEN:
	    					description = getString(R.string.dialogDescriptionHeavenEmpty);
	    					title = getString(R.string.dialogTitleHeavenEmpty);
	    					break;
	    				case Values.SCENARIO_HELL:
	    					description = getString(R.string.dialogDescriptionHellEmpty);
	    					title = getString(R.string.dialogTitleHellEmpty);
	    					break;
	    			}
	    			icon = R.drawable.icon_empty;
	    			river = false;
	    		}
	    		destroyable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		break;
	    	//Level 1 Areas
	    	case Values.BUILDING_MAROON_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellMaroon1);
	    				description = getString(R.string.hellMaroon1Description)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_maroon_0;
	    				else
	    					icon = R.drawable.icon_maroon_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenMaroon1);
	    				description = getString(R.string.heavenMaroon1Description)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_maroon_0;
	    				else
	    					icon = R.drawable.icon_maroon_1_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PINK_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPink1);
	    				description = getString(R.string.hellPink1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_pink_0;
	    				else
	    					icon = R.drawable.icon_pink_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPink1);
	    				description = getString(R.string.heavenPink1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_pink_0;
	    				else
	    					icon = R.drawable.icon_pink_1_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_YELLOW_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellYellow1);
	    				description = getString(R.string.hellYellow1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_yellow_0;
	    				else
	    					icon = R.drawable.icon_yellow_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenYellow1);
	    				description = getString(R.string.heavenYellow1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_yellow_0;
	    				else
	    					icon = R.drawable.icon_yellow_1_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_BLUE_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellBlue1);
	    				description = getString(R.string.hellBlue1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_blue_0;
	    				else
	    					icon = R.drawable.icon_blue_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenBlue1);
	    				description = getString(R.string.heavenBlue1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_blue_0;
	    				else
	    					icon = R.drawable.icon_blue_1_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_RED_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellRed1);
	    				description = getString(R.string.hellRed1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_red_0;
	    				else
	    					icon = R.drawable.icon_red_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenRed1);
	    				description = getString(R.string.heavenRed1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_red_0;
	    				else
	    					icon = R.drawable.icon_red_1_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_GREEN_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellGreen1);
	    				description = getString(R.string.hellGreen1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_green_0;
	    				else
	    					icon = R.drawable.icon_green_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenGreen1);
	    				description = getString(R.string.heavenGreen1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_green_0;
	    				else
	    					icon = R.drawable.icon_green_1_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PURPLE_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPurple1);
	    				description = getString(R.string.hellRed1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_purple_0;
	    				else
	    					icon = R.drawable.icon_purple_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPurple1);
	    				description = getString(R.string.heavenPurple1Description) + "\n\n" + getString(R.string.textCanHost, Values.HOSTING_1_CAPACITY);
	    				if (gameView.box[box].getAge() < Values.AGE_1)
	    					icon = R.drawable.icon_purple_0;
	    				else
	    					icon = R.drawable.icon_purple_1_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	//Level 2 Areas
	    	case Values.BUILDING_MAROON_2_BAD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellMaroon2Bad);
	    				description = getString(R.string.hellMaroon2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_maroon_2_bad_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenMaroon2Bad);
	    				description = getString(R.string.heavenMaroon2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_maroon_2_bad_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_MAROON_2_NEUTRAL:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellMaroon2Neutral);
	    				description = getString(R.string.hellMaroon2NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_maroon_2_neutral_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenMaroon2Neutral);
	    				description = getString(R.string.heavenMaroon2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_maroon_2_neutral_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_MAROON_2_GOOD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellMaroon2Good);
	    				description = getString(R.string.hellMaroon2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_maroon_2_good_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenMaroon2Good);
	    				description = getString(R.string.heavenMaroon2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_maroon_2_good_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PINK_2_BAD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPink2Bad);
	    				description = getString(R.string.hellPink2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_pink_2_bad_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPink2Bad);
	    				description = getString(R.string.heavenPink2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_pink_2_bad_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PINK_2_NEUTRAL:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPink2Neutral);
	    				description = getString(R.string.hellPink2NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_pink_2_neutral_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPink2Neutral);
	    				description = getString(R.string.heavenPink2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_pink_2_neutral_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PINK_2_GOOD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPink2Good);
	    				description = getString(R.string.hellPink2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_pink_2_good_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPink2Good);
	    				description = getString(R.string.heavenPink2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_pink_2_good_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_YELLOW_2_BAD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellYellow2Bad);
	    				description = getString(R.string.hellYellow2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_yellow_2_bad_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenYellow2Bad);
	    				description = getString(R.string.heavenYellow2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_yellow_2_bad_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_YELLOW_2_NEUTRAL:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellYellow2Neutral);
	    				description = getString(R.string.hellYellow2NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_yellow_2_neutral_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenYellow2Neutral);
	    				description = getString(R.string.heavenYellow2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_yellow_2_neutral_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_YELLOW_2_GOOD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellYellow2Good);
	    				description = getString(R.string.hellYellow2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_yellow_2_good_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenYellow2Good);
	    				description = getString(R.string.heavenYellow2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_yellow_2_good_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_BLUE_2_BAD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellBlue2Bad);
	    				description = getString(R.string.hellBlue2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_blue_2_bad_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenBlue2Bad);
	    				description = getString(R.string.heavenBlue2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_blue_2_bad_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_BLUE_2_NEUTRAL:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellBlue2Neutral);
	    				description = getString(R.string.hellBlue2NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_blue_2_neutral_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenBlue2Neutral);
	    				description = getString(R.string.heavenBlue2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_blue_2_neutral_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_BLUE_2_GOOD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellBlue2Good);
	    				description = getString(R.string.hellBlue2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_blue_2_good_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenBlue2Good);
	    				description = getString(R.string.heavenBlue2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_blue_2_good_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_RED_2_BAD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellRed2Bad);
	    				description = getString(R.string.hellRed2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_red_2_bad_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenRed2Bad);
	    				description = getString(R.string.heavenRed2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_red_2_bad_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_RED_2_NEUTRAL:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellRed2Neutral);
	    				description = getString(R.string.hellRed2NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_red_2_neutral_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenRed2Neutral);
	    				description = getString(R.string.heavenRed2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_red_2_neutral_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_RED_2_GOOD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellRed2Good);
	    				description = getString(R.string.hellRed2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_red_2_good_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenRed2Good);
	    				description = getString(R.string.heavenRed2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_red_2_good_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_GREEN_2_BAD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellGreen2Bad);
	    				description = getString(R.string.hellGreen2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_green_2_bad_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenGreen2Bad);
	    				description = getString(R.string.heavenGreen2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_green_2_bad_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_GREEN_2_NEUTRAL:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellGreen2Neutral);
	    				description = getString(R.string.hellGreen2NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_green_2_neutral_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenGreen2Neutral);
	    				description = getString(R.string.heavenGreen2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_green_2_neutral_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_GREEN_2_GOOD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellGreen2Good);
	    				description = getString(R.string.hellGreen2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_green_2_good_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenGreen2Good);
	    				description = getString(R.string.heavenGreen2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_green_2_good_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PURPLE_2_BAD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPurple2Bad);
	    				description = getString(R.string.hellPurple2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_purple_2_bad_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPurple2Bad);
	    				description = getString(R.string.heavenPurple2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_BAD_CAPACITY);
	    				icon = R.drawable.icon_purple_2_bad_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PURPLE_2_NEUTRAL:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPurple2Neutral);
	    				description = getString(R.string.hellPurple2NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_purple_2_neutral_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPurple2Neutral);
	    				description = getString(R.string.heavenPurple2BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_NEUTRAL_CAPACITY);
	    				icon = R.drawable.icon_purple_2_neutral_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_PURPLE_2_GOOD:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellPurple2Good);
	    				description = getString(R.string.hellPurple2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_purple_2_good_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenPurple2Good);
	    				description = getString(R.string.heavenPurple2GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_2_GOOD_CAPACITY);
	    				icon = R.drawable.icon_purple_2_good_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    		//Level 3 Areas
		    	case Values.BUILDING_MAROON_3_BAD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellMaroon3Bad);
		    				description = getString(R.string.hellMaroon3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_maroon_3_bad_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenMaroon3Bad);
		    				description = getString(R.string.heavenMaroon3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_maroon_3_bad_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_MAROON_3_NEUTRAL:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellMaroon3Neutral);
		    				description = getString(R.string.hellMaroon3NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_maroon_3_neutral_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenMaroon3Neutral);
		    				description = getString(R.string.heavenMaroon3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_maroon_3_neutral_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_MAROON_3_GOOD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellMaroon3Good);
		    				description = getString(R.string.hellMaroon3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_maroon_3_good_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenMaroon3Good);
		    				description = getString(R.string.heavenMaroon3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_maroon_3_good_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_PINK_3_BAD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellPink3Bad);
		    				description = getString(R.string.hellPink3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_pink_3_bad_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenPink3Bad);
		    				description = getString(R.string.heavenPink3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_pink_3_bad_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_PINK_3_NEUTRAL:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellPink3Neutral);
		    				description = getString(R.string.hellPink3NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_pink_3_neutral_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenPink3Neutral);
		    				description = getString(R.string.heavenPink3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_pink_3_neutral_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_PINK_3_GOOD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellPink3Good);
		    				description = getString(R.string.hellPink3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_pink_3_good_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenPink3Good);
		    				description = getString(R.string.heavenPink3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_pink_3_good_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_YELLOW_3_BAD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellYellow3Bad);
		    				description = getString(R.string.hellYellow3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_yellow_3_bad_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenYellow3Bad);
		    				description = getString(R.string.heavenYellow3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_yellow_3_bad_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_YELLOW_3_NEUTRAL:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellYellow3Neutral);
		    				description = getString(R.string.hellYellow3NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_yellow_3_neutral_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenYellow3Neutral);
		    				description = getString(R.string.heavenYellow3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_yellow_3_neutral_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_YELLOW_3_GOOD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellYellow3Good);
		    				description = getString(R.string.hellYellow3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_yellow_3_good_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenYellow3Good);
		    				description = getString(R.string.heavenYellow3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_yellow_3_good_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_BLUE_3_BAD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellBlue3Bad);
		    				description = getString(R.string.hellBlue3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_blue_3_bad_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenBlue3Bad);
		    				description = getString(R.string.heavenBlue3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_blue_3_bad_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_BLUE_3_NEUTRAL:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellBlue3Neutral);
		    				description = getString(R.string.hellBlue3NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_blue_3_neutral_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenBlue3Neutral);
		    				description = getString(R.string.heavenBlue3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_blue_3_neutral_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_BLUE_3_GOOD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellBlue3Good);
		    				description = getString(R.string.hellBlue3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_blue_3_good_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenBlue3Good);
		    				description = getString(R.string.heavenBlue3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_blue_3_good_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_RED_3_BAD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellRed3Bad);
		    				description = getString(R.string.hellRed3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_red_3_bad_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenRed3Bad);
		    				description = getString(R.string.heavenRed3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_red_3_bad_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_RED_3_NEUTRAL:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellRed3Neutral);
		    				description = getString(R.string.hellRed3NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_red_3_neutral_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenRed3Neutral);
		    				description = getString(R.string.heavenRed3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_red_3_neutral_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_RED_3_GOOD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellRed3Good);
		    				description = getString(R.string.hellRed3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_red_3_good_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenRed3Good);
		    				description = getString(R.string.heavenRed3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_red_3_good_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_GREEN_3_BAD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellGreen3Bad);
		    				description = getString(R.string.hellGreen3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_green_3_bad_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenGreen3Bad);
		    				description = getString(R.string.heavenGreen3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_green_3_bad_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_GREEN_3_NEUTRAL:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellGreen3Neutral);
		    				description = getString(R.string.hellGreen3NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_green_3_neutral_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenGreen3Neutral);
		    				description = getString(R.string.heavenGreen3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_green_3_neutral_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_GREEN_3_GOOD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellGreen3Good);
		    				description = getString(R.string.hellGreen3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_green_3_good_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenGreen3Good);
		    				description = getString(R.string.heavenGreen3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_green_3_good_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_PURPLE_3_BAD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellPurple3Bad);
		    				description = getString(R.string.hellPurple3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_purple_3_bad_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenPurple3Bad);
		    				description = getString(R.string.heavenPurple3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_BAD_CAPACITY);
		    				icon = R.drawable.icon_purple_3_bad_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_PURPLE_3_NEUTRAL:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellPurple3Neutral);
		    				description = getString(R.string.hellPurple3NeutralDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_purple_3_neutral_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenPurple3Neutral);
		    				description = getString(R.string.heavenPurple3BadDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_NEUTRAL_CAPACITY);
		    				icon = R.drawable.icon_purple_3_neutral_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
		    	case Values.BUILDING_PURPLE_3_GOOD:
		    		switch (scenario){
		    			case Values.SCENARIO_HELL: 
		    				title = getString(R.string.hellPurple3Good);
		    				description = getString(R.string.hellPurple3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_purple_3_good_hell;
		    				break;
		    			case Values.SCENARIO_HEAVEN:
		    				title = getString(R.string.heavenPurple3Good);
		    				description = getString(R.string.heavenPurple3GoodDescription)+ "\n\n" + getString(R.string.textCanHost, Values.HOSTING_3_GOOD_CAPACITY);
		    				icon = R.drawable.icon_purple_3_good_heaven;
		    				break;
		    		}
		    		buildable = false;
		    		upgradeable = false;
		    		parametrizable = false;
		    		river = false;
		    		break;
	    	//Level 1 buildings
	    	case Values.BUILDING_DOOR_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellDoor1);
	    				description = getString(R.string.helldoor1Description) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_1_INPUT);
	    				upgradeText = getString(R.string.hellDoor2) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_2_INPUT) + "\n\n" + Integer.toString(Values.DOOR_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_door_2_hell;
	    				icon = R.drawable.icon_door_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor1);
	    				description = getString(R.string.heavendoor1Description) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_1_INPUT);
	    				upgradeText = getString(R.string.heavenDoor2) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_2_INPUT) + "\n\n" + Integer.toString(Values.DOOR_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_door_2_heaven;
	    				icon = R.drawable.icon_door_1_heaven;
	    				break;
	    		}
	    		nextBuilding = Values.BUILDING_DOOR_2;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_ACADEMY_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellAcademy1);
	    				description = getString(R.string.hellcenter1Description) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_1_TRAIN);
	    				upgradeText = getString(R.string.hellAcademy2) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_2_TRAIN) + "\n\n" + Integer.toString(Values.DOOR_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_academy_2_hell;
	    				icon = R.drawable.icon_academy_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor1);
	    				description = getString(R.string.heavencenter1Description) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_1_TRAIN);
	    				upgradeText = getString(R.string.heavenAcademy2) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_2_TRAIN) + "\n\n" + Integer.toString(Values.DOOR_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_academy_2_heaven;
	    				icon = R.drawable.icon_academy_1_heaven;
	    				break;
	    		}
	    		nextBuilding = Values.BUILDING_ACADEMY_2;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_TOPIA_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellTopia1);
	    				description = getString(R.string.helltopia1Description) + "\n\n" + getString(R.string.textCanHouseDemons, Values.TOPIA_1_BEDS);
	    				upgradeText = getString(R.string.hellTopia2) + "\n\n" + getString(R.string.textCanHouseDemons, Values.TOPIA_2_BEDS) + "\n\n" + Integer.toString(Values.TOPIA_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_topia_2_hell;
	    				icon = R.drawable.icon_topia_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenTopia1);
	    				description = getString(R.string.heaventopia1Description) + "\n\n" + getString(R.string.textCanHouseAngels, Values.TOPIA_1_BEDS);
	    				upgradeText = getString(R.string.heavenTopia2) + "\n\n" + getString(R.string.textCanHouseAngels, Values.TOPIA_2_BEDS) + "\n\n" + Integer.toString(Values.TOPIA_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_topia_2_heaven;
	    				icon = R.drawable.icon_topia_1_heaven;
	    				break;
	    		}
	    		parametrizable = false;
	    		nextBuilding = Values.BUILDING_TOPIA_2;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_STATION_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellStation1);
	    				description = getString(R.string.hellstation1Description) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_1_TICKETS);
	    				upgradeText = getString(R.string.hellStation2) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_2_TICKETS) + "\n\n" + Integer.toString(Values.STATION_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_station_2_hell;
	    				icon = R.drawable.icon_station_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor1);
	    				description = getString(R.string.heavenstation1Description) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_1_TICKETS);
	    				upgradeText = getString(R.string.heavenStation2) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_2_TICKETS) + "\n\n" + Integer.toString(Values.STATION_2_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_station_2_heaven;
	    				icon = R.drawable.icon_station_1_heaven;
	    				break;
	    		}
	    		parametrizable = false;
	    		nextBuilding = Values.BUILDING_STATION_2;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_SIPHON_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				upgradeIcon = R.drawable.icon_siphon_2_hell;
	    				icon = R.drawable.icon_siphon_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				upgradeIcon = R.drawable.icon_siphon_2_heaven;
	    				icon = R.drawable.icon_siphon_1_heaven;
	    				break;
	    		}
	    		title = getString(R.string.siphon1);
				description = getString(R.string.siphon1Description) + "\n\n" + getString(R.string.textCanProduce, Values.SIPHON_1_PRODUCTION);
				upgradeText = getString(R.string.siphon2) + "\n\n" + getString(R.string.textCanProduce, Values.SIPHON_2_PRODUCTION) + "\n\n" + Integer.toString(Values.SIPHON_2_PRICE) + "ł";
	    		nextBuilding = Values.BUILDING_SIPHON_2;
	    		buildable = false;
	    		river = false;
	    		parametrizable = false;
	    		break;
	    	case Values.BUILDING_SPECIAL_1:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellSpecial1);
	    				description = getString(R.string.hellspecial1Description);
	    				icon = R.drawable.icon_special_1_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenSpecial1);
	    				description = getString(R.string.heavenspecial1Description);
	    				icon = R.drawable.icon_special_1_heaven;
	    				break;
	    		}
	    		parametrizable = false;
	    		destroyable = false;
	    		upgradeable = false;
	    		buildable = false;
	    		river = false;
	    		break;
    		//Level 2 buildings
	    	case Values.BUILDING_DOOR_2:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellDoor2);
	    				description = getString(R.string.helldoor2Description) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_2_INPUT);
	    				upgradeText = getString(R.string.hellDoor3) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_3_INPUT) + "\n\n" + Integer.toString(Values.DOOR_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_door_3_hell;
	    				icon = R.drawable.icon_door_2_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor2);
	    				description = getString(R.string.heavendoor2Description) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_2_INPUT);
	    				upgradeText = getString(R.string.heavenDoor3) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_3_INPUT) + "\n\n" + Integer.toString(Values.DOOR_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_door_3_heaven;
	    				icon = R.drawable.icon_door_2_heaven;
	    				break;
	    		}
	    		nextBuilding = Values.BUILDING_DOOR_3;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_ACADEMY_2:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellAcademy2);
	    				description = getString(R.string.hellcenter2Description) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_2_TRAIN);
	    				upgradeText = getString(R.string.hellAcademy3) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_3_TRAIN) + "\n\n" + Integer.toString(Values.DOOR_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_academy_3_hell;
	    				icon = R.drawable.icon_academy_2_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor2);
	    				description = getString(R.string.heavencenter2Description) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_2_TRAIN);
	    				upgradeText = getString(R.string.heavenAcademy3) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_3_TRAIN) + "\n\n" + Integer.toString(Values.DOOR_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_academy_3_heaven;
	    				icon = R.drawable.icon_academy_2_heaven;
	    				break;
	    		}
	    		nextBuilding = Values.BUILDING_ACADEMY_3;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_TOPIA_2:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellTopia2);
	    				description = getString(R.string.helltopia2Description) + "\n\n" + getString(R.string.textCanHouseDemons, Values.TOPIA_2_BEDS);
	    				upgradeText = getString(R.string.hellTopia3) + "\n\n" + getString(R.string.textCanHouseDemons, Values.TOPIA_3_BEDS) + "\n\n" + Integer.toString(Values.TOPIA_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_topia_3_hell;
	    				icon = R.drawable.icon_topia_2_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenTopia2);
	    				description = getString(R.string.heaventopia2Description) + "\n\n" + getString(R.string.textCanHouseAngels, Values.TOPIA_2_BEDS);
	    				upgradeText = getString(R.string.heavenTopia3) + "\n\n" + getString(R.string.textCanHouseAngels, Values.TOPIA_3_BEDS) + "\n\n" + Integer.toString(Values.TOPIA_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_topia_3_heaven;
	    				icon = R.drawable.icon_topia_2_heaven;
	    				break;
	    		}
	    		nextBuilding = Values.BUILDING_TOPIA_3;
	    		buildable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_STATION_2:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellStation2);
	    				description = getString(R.string.hellstation2Description) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_2_TICKETS);
	    				upgradeText = getString(R.string.hellStation3) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_3_TICKETS) + "\n\n" + Integer.toString(Values.STATION_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_station_3_hell;
	    				icon = R.drawable.icon_station_2_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor2);
	    				description = getString(R.string.heavenstation2Description) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_2_TICKETS);
	    				upgradeText = getString(R.string.heavenStation3) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_3_TICKETS) + "\n\n" + Integer.toString(Values.STATION_3_PRICE) + "ł";
	    				upgradeIcon = R.drawable.icon_station_3_heaven;
	    				icon = R.drawable.icon_station_2_heaven;
	    				break;
	    		}
	    		nextBuilding = Values.BUILDING_STATION_3;
	    		buildable = false;
	    		parametrizable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_SIPHON_2:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				upgradeIcon = R.drawable.icon_siphon_3_hell;
	    				icon = R.drawable.icon_siphon_2_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				upgradeIcon = R.drawable.icon_siphon_3_heaven;
	    				icon = R.drawable.icon_siphon_2_heaven;
	    				break;
	    		}
	    		title = getString(R.string.siphon2);
				description = getString(R.string.siphon2Description) + "\n\n" + getString(R.string.textCanProduce, Values.SIPHON_2_PRODUCTION);
				upgradeText = getString(R.string.siphon3) + "\n\n" + getString(R.string.textCanProduce, Values.SIPHON_3_PRODUCTION) + "\n\n" + Integer.toString(Values.SIPHON_3_PRICE) + "ł";
	    		nextBuilding = Values.BUILDING_SIPHON_3;
	    		buildable = false;
	    		river = false;
	    		parametrizable = false;
	    		break;
	    	case Values.BUILDING_SPECIAL_2:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellSpecial2);
	    				description = getString(R.string.hellspecial2Description);
	    				icon = R.drawable.icon_special_2_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenSpecial2);
	    				description = getString(R.string.heavenspecial2Description);
	    				icon = R.drawable.icon_special_2_heaven;
	    				break;
	    		}
	    		destroyable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		buildable = false;
	    		river = false;
	    		break;
    		//Level 3 buildings
	    	case Values.BUILDING_DOOR_3:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellDoor3);
	    				description = getString(R.string.helldoor3Description) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_3_INPUT);
	    				icon = R.drawable.icon_door_3_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor3);
	    				description = getString(R.string.heavendoor3Description) + "\n\n" + getString(R.string.textAllowsEntrance, Values.DOOR_3_INPUT);
	    				icon = R.drawable.icon_door_3_heaven;
	    				break;
	    		}
	    		upgradeable = false;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_ACADEMY_3:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellAcademy3);
	    				description = getString(R.string.hellcenter3Description) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_3_TRAIN);
	    				icon = R.drawable.icon_academy_3_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor3);
	    				description = getString(R.string.heavencenter3Description) + "\n\n" + getString(R.string.textCapacityAlumni, Values.ACADEMY_3_TRAIN);
	    				icon = R.drawable.icon_academy_3_heaven;
	    				break;
	    		}
	    		upgradeable = false;
	    		buildable = false;
	    		river = false;
	    		break;
	    	case Values.BUILDING_TOPIA_3:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellTopia3);
	    				description = getString(R.string.helltopia3Description) + "\n\n" + getString(R.string.textCanHouseDemons, Values.TOPIA_3_BEDS);
	    				icon = R.drawable.icon_topia_3_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenTopia3);
	    				description = getString(R.string.heaventopia3Description) + "\n\n" + getString(R.string.textCanHouseAngels, Values.TOPIA_3_BEDS);
	    				icon = R.drawable.icon_topia_3_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		river = false;
	    		parametrizable = false;
	    		upgradeable = false;
	    		break;
	    	case Values.BUILDING_STATION_3:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellStation3);
	    				description = getString(R.string.hellstation3Description) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_3_TICKETS);
	    				icon = R.drawable.icon_station_3_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenDoor3);
	    				description = getString(R.string.heavenstation3Description) + "\n\n" + getString(R.string.textCanReincarnate, Values.STATION_3_TICKETS);
	    				icon = R.drawable.icon_station_3_heaven;
	    				break;
	    		}
	    		buildable = false;
	    		river = false;
	    		parametrizable = false;
	    		upgradeable = false;
	    		break;
	    	case Values.BUILDING_SIPHON_3:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				icon = R.drawable.icon_siphon_3_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				icon = R.drawable.icon_siphon_3_heaven;
	    				break;
	    		}
	    		title = getString(R.string.siphon3);
				description = getString(R.string.siphon3Description) + "\n\n" + getString(R.string.textCanProduce, Values.SIPHON_3_PRODUCTION);
	    		buildable = false;
	    		river = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		break;
	    	case Values.BUILDING_SPECIAL_3:
	    		switch (scenario){
	    			case Values.SCENARIO_HELL: 
	    				title = getString(R.string.hellSpecial3);
	    				description = getString(R.string.hellspecial3Description);
	    				icon = R.drawable.icon_special_3_hell;
	    				break;
	    			case Values.SCENARIO_HEAVEN:
	    				title = getString(R.string.heavenSpecial3);
	    				icon = R.drawable.icon_special_3_heaven;
	    				break;
	    		}
	    		destroyable = false;
	    		upgradeable = false;
	    		parametrizable = false;
	    		buildable = false;
	    		river = false;
	    		break;
	    }
	    //Append vibes strings to description
	    description = description + emitting + under;
	    //Group info in arrays
	    boolean[] booleans = {buildable, river, upgradeable, destroyable, parametrizable};
	    int[] integers = {box, gameView.getScreenDimensions()[0], value, maxValue, icon, upgradeIcon, nextBuilding};
	    String[] strings = {title, description, upgradeText, barTitle, barText};
	    //Sets the options to configure the dialog...
	    newFragment.setData(scenario, booleans, integers, strings);
	    //... and show it
	    newFragment.show(fragmentManager, "info" + Integer.toString(box));
	    
	}
	
	//Play sound, passed as the integer reference in R
	public void play(int sound){
		MediaPlayer mp;
		if (prefFX){
			mp = MediaPlayer.create(getApplicationContext(), sound);        										
			mp.start();
		}
	}
	//Play or stop when recieving reward buildings
	public void playSpecial(boolean stop){
		if(prefFX){
			if (stop)
				specialPlayer.stop();
			else{
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						specialPlayer = MediaPlayer.create(getApplicationContext(), R.raw.heavenspecial);
						break;
					case Values.SCENARIO_HELL:
						specialPlayer = MediaPlayer.create(getApplicationContext(), R.raw.hellspecial);
						break;
				}       										
				specialPlayer.start();
			}
		}
	}
	
	//Code to build "building" in box "box"
	public void build(int box, int building){
		//TODO: Group cases
		//Switch the building, and check required conditions
		//TODO: Infinite debt cheat must be implemented here
		switch (building){
			//Level 1 areas
			case Values.BUILDING_MAROON_1:
				if (money < Values.HOSTING_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.HOSTING_1_PRICE;
				play(R.raw.click);
				gameView.build(box, building, false);
				gameView.box[box].setHosting(0, Values.HOSTING_1_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_1_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_1_VIBES);
				break;
			case Values.BUILDING_PINK_1:
				if (money < Values.HOSTING_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.HOSTING_1_PRICE;
				play(R.raw.click);
				gameView.build(box, building, false);
				gameView.box[box].setHosting(1, Values.HOSTING_1_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_1_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_1_VIBES);
				break;
			case Values.BUILDING_YELLOW_1:
				if (money < Values.HOSTING_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.HOSTING_1_PRICE;
				play(R.raw.click);
				gameView.build(box, building, false);
				gameView.build(box, building, false);
				gameView.box[box].setHosting(2, Values.HOSTING_1_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_1_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_1_VIBES);
				break;
			case Values.BUILDING_BLUE_1:
				if (money < Values.HOSTING_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.HOSTING_1_PRICE;
				play(R.raw.click);
				gameView.build(box, building, false);
				gameView.box[box].setHosting(3, Values.HOSTING_1_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_1_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_1_VIBES);
				break;
			case Values.BUILDING_RED_1:
				if (money < Values.HOSTING_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.HOSTING_1_PRICE;
				play(R.raw.click);
				gameView.build(box, building, false);
				gameView.box[box].setHosting(4, Values.HOSTING_1_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_1_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_1_VIBES);
				break;
			case Values.BUILDING_GREEN_1:
				if (money < Values.HOSTING_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.HOSTING_1_PRICE;
				play(R.raw.click);
				gameView.build(box, building, false);
				gameView.box[box].setHosting(5, Values.HOSTING_1_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_1_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_1_VIBES);
				break;
			case Values.BUILDING_PURPLE_1:
				if (money < Values.HOSTING_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.HOSTING_1_PRICE;
				play(R.raw.click);
				gameView.build(box, building, false);
				gameView.box[box].setHosting(6, Values.HOSTING_1_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_1_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_1_VIBES);
				break;
			//Level 2 areas
			case Values.BUILDING_MAROON_2_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(0, Values.HOSTING_2_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_BAD_VIBES);
				break;
			case Values.BUILDING_PINK_2_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(1, Values.HOSTING_2_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_BAD_VIBES);
				break;
			case Values.BUILDING_YELLOW_2_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(2, Values.HOSTING_2_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_BAD_VIBES);
				break;
			case Values.BUILDING_BLUE_2_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(3, Values.HOSTING_2_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_BAD_VIBES);
				break;
			case Values.BUILDING_RED_2_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(4, Values.HOSTING_2_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_BAD_VIBES);
				break;
			case Values.BUILDING_GREEN_2_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(5, Values.HOSTING_2_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_BAD_VIBES);
				break;
			case Values.BUILDING_PURPLE_2_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(6, Values.HOSTING_2_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_BAD_VIBES);
				break;
			case Values.BUILDING_MAROON_2_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(0, Values.HOSTING_2_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_PINK_2_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(1, Values.HOSTING_2_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_YELLOW_2_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(2, Values.HOSTING_2_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_BLUE_2_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(3, Values.HOSTING_2_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_RED_2_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(4, Values.HOSTING_2_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_GREEN_2_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(5, Values.HOSTING_2_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_PURPLE_2_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(6, Values.HOSTING_2_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_MAROON_2_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(0, Values.HOSTING_2_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_GOOD_VIBES);
				break;
			case Values.BUILDING_PINK_2_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(1, Values.HOSTING_2_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_GOOD_VIBES);
				break;
			case Values.BUILDING_YELLOW_2_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(2, Values.HOSTING_2_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_GOOD_VIBES);
				break;
			case Values.BUILDING_BLUE_2_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(3, Values.HOSTING_2_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_GOOD_VIBES);
				break;
			case Values.BUILDING_RED_2_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(4, Values.HOSTING_2_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_GOOD_VIBES);
				break;
			case Values.BUILDING_GREEN_2_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(5, Values.HOSTING_2_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_GOOD_VIBES);
				break;
			case Values.BUILDING_PURPLE_2_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(6, Values.HOSTING_2_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_2_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_2_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_2_GOOD_VIBES);
				break;
			//Level 3 areas
			case Values.BUILDING_MAROON_3_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(0, Values.HOSTING_3_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_BAD_VIBES);
				break;
			case Values.BUILDING_PINK_3_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(1, Values.HOSTING_3_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_BAD_VIBES);
				break;
			case Values.BUILDING_YELLOW_3_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(2, Values.HOSTING_3_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_BAD_VIBES);
				break;
			case Values.BUILDING_BLUE_3_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(3, Values.HOSTING_3_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_BAD_VIBES);
				break;
			case Values.BUILDING_RED_3_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(4, Values.HOSTING_3_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_BAD_VIBES);
				break;
			case Values.BUILDING_GREEN_3_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(5, Values.HOSTING_3_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_BAD_VIBES);
				break;
			case Values.BUILDING_PURPLE_3_BAD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(6, Values.HOSTING_3_BAD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_BAD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_BAD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_BAD_VIBES);
				break;
			case Values.BUILDING_MAROON_3_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(0, Values.HOSTING_3_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_PINK_3_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(1, Values.HOSTING_3_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_YELLOW_3_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(2, Values.HOSTING_3_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_BLUE_3_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(3, Values.HOSTING_3_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_RED_3_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(4, Values.HOSTING_3_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_GREEN_3_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(5, Values.HOSTING_3_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_PURPLE_3_NEUTRAL:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(6, Values.HOSTING_3_NEUTRAL_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_NEUTRAL_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_NEUTRAL_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_NEUTRAL_VIBES);
				break;
			case Values.BUILDING_MAROON_3_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(0, Values.HOSTING_3_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_GOOD_VIBES);
				break;
			case Values.BUILDING_PINK_3_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(1, Values.HOSTING_3_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_GOOD_VIBES);
				break;
			case Values.BUILDING_YELLOW_3_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(2, Values.HOSTING_3_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_GOOD_VIBES);
				break;
			case Values.BUILDING_BLUE_3_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(3, Values.HOSTING_3_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_GOOD_VIBES);
				break;
			case Values.BUILDING_RED_3_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(4, Values.HOSTING_3_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_GOOD_VIBES);
				break;
			case Values.BUILDING_GREEN_3_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(5, Values.HOSTING_3_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_GOOD_VIBES);
				break;
			case Values.BUILDING_PURPLE_3_GOOD:
				play(R.raw.click);
				gameView.build(box, building, true);
				gameView.box[box].setHosting(6, Values.HOSTING_3_GOOD_CAPACITY);
				gameView.box[box].setConsumption(Values.HOSTING_3_GOOD_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.HOSTING_3_GOOD_WORKERS);
				gameView.box[box].setVibes(Values.HOSTING_3_GOOD_VIBES);
				break;
			//Level 1 buildings
			case Values.BUILDING_DOOR_1:
				if (money < Values.DOOR_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.DOOR_1_PRICE;
				gameView.build(box, building, false);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heavendoor);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.helldoor);
						break;
				}
				gameView.box[box].setInputCapacity(Values.DOOR_1_INPUT);
				gameView.box[box].setConsumption(Values.DOOR_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.DOOR_1_WORKERS);
				gameView.box[box].setVibes(Values.DOOR_1_VIBES);
				break;
			case Values.BUILDING_ACADEMY_1:
				if (money < Values.ACADEMY_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.ACADEMY_1_PRICE;
				gameView.build(box, building, false);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heavenacademy);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.hellacademy);
						break;
				}
				gameView.box[box].setStudyplaces(Values.ACADEMY_1_TRAIN);
				gameView.box[box].setConsumption(Values.ACADEMY_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.ACADEMY_1_WORKERS);
				gameView.box[box].setVibes(Values.ACADEMY_1_VIBES);
				break;
			case Values.BUILDING_TOPIA_1:
				if (money < Values.TOPIA_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.TOPIA_1_PRICE;
				gameView.build(box, building, false);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heaventopia);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.helltopia);
						break;
				}
				gameView.box[box].setBeds(Values.TOPIA_1_BEDS);
				gameView.box[box].setConsumption(Values.TOPIA_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.TOPIA_1_WORKERS);
				gameView.box[box].setVibes(Values.TOPIA_1_VIBES);
				break;
			case Values.BUILDING_STATION_1:
				if (money < Values.STATION_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.STATION_1_PRICE;
				gameView.build(box, building, false);
				play(R.raw.station);
				gameView.box[box].setCars(Values.STATION_1_TICKETS);
				gameView.box[box].setConsumption(Values.STATION_1_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.STATION_1_WORKERS);
				gameView.box[box].setVibes(Values.STATION_1_VIBES);
				break;
			case Values.BUILDING_SIPHON_1:
				if (money < Values.SIPHON_1_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.SIPHON_1_PRICE;
				gameView.build(box, building, false);
				play(R.raw.siphon);
				gameView.box[box].setProduction(Values.SIPHON_1_PRODUCTION);
				gameView.box[box].setWorkplaces(Values.SIPHON_1_PRODUCTION);
				gameView.box[box].setVibes(Values.SIPHON_1_VIBES);
				break;
			case Values.BUILDING_SPECIAL_1:
				gameView.build(box, building, false);
				gameView.box[box].setVibes(Values.SPECIAL_1_VIBES);
				break;
			//Level 2 buildings
			case Values.BUILDING_DOOR_2:
				if (money < Values.DOOR_2_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.DOOR_2_PRICE;
				gameView.build(box, building, true);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heavendoor);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.helldoor);
						break;
				}
				gameView.box[box].setInputCapacity(Values.DOOR_2_INPUT);
				gameView.box[box].setConsumption(Values.DOOR_2_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.DOOR_2_WORKERS);
				gameView.box[box].setVibes(Values.DOOR_2_VIBES);
				break;
			case Values.BUILDING_ACADEMY_2:
				if (money < Values.ACADEMY_2_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.ACADEMY_2_PRICE;
				gameView.build(box, building, true);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heavenacademy);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.hellacademy);
						break;
				}
				gameView.box[box].setStudyplaces(Values.ACADEMY_2_TRAIN);
				gameView.box[box].setConsumption(Values.ACADEMY_2_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.ACADEMY_2_WORKERS);
				gameView.box[box].setVibes(Values.ACADEMY_2_VIBES);
				break;
			case Values.BUILDING_TOPIA_2:
				if (money < Values.TOPIA_2_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.TOPIA_2_PRICE;
				gameView.build(box, building, true);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heaventopia);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.helltopia);
						break;
				}
				gameView.box[box].setBeds(Values.TOPIA_2_BEDS);
				gameView.box[box].setConsumption(Values.TOPIA_2_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.TOPIA_2_WORKERS);
				gameView.box[box].setVibes(Values.TOPIA_2_VIBES);
				break;
			case Values.BUILDING_STATION_2:
				if (money < Values.STATION_2_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.STATION_2_PRICE;
				gameView.build(box, building, true);
				play(R.raw.station);
				gameView.box[box].setCars(Values.STATION_2_TICKETS);
				gameView.box[box].setConsumption(Values.STATION_2_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.STATION_2_WORKERS);
				gameView.box[box].setVibes(Values.STATION_2_VIBES);
				break;
			case Values.BUILDING_SIPHON_2:
				if (money < Values.SIPHON_2_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.SIPHON_2_PRICE;
				gameView.build(box, building, true);
				play(R.raw.siphon);
				gameView.box[box].setProduction(Values.SIPHON_2_PRODUCTION);
				gameView.box[box].setWorkplaces(Values.SIPHON_2_PRODUCTION);
				gameView.box[box].setVibes(Values.SIPHON_2_VIBES);
				break;
			case Values.BUILDING_SPECIAL_2:
				gameView.build(box, building, true);
				gameView.box[box].setVibes(Values.SPECIAL_2_VIBES);
				break;
			//Level 3 buildings
			case Values.BUILDING_DOOR_3:
				if (money < Values.DOOR_3_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.DOOR_3_PRICE;
				gameView.build(box, building, true);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heavendoor);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.helldoor);
						break;
				}
				gameView.box[box].setInputCapacity(Values.DOOR_3_INPUT);
				gameView.box[box].setConsumption(Values.DOOR_3_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.DOOR_3_WORKERS);
				gameView.box[box].setVibes(Values.DOOR_3_VIBES);
				break;
			case Values.BUILDING_ACADEMY_3:
				if (money < Values.ACADEMY_3_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.ACADEMY_3_PRICE;
				gameView.build(box, building, true);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heavenacademy);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.hellacademy);
						break;
				}
				gameView.box[box].setStudyplaces(Values.ACADEMY_3_TRAIN);
				gameView.box[box].setConsumption(Values.ACADEMY_3_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.ACADEMY_3_WORKERS);
				gameView.box[box].setVibes(Values.ACADEMY_3_VIBES);
				break;
			case Values.BUILDING_TOPIA_3:
				if (money < Values.TOPIA_3_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.TOPIA_3_PRICE;
				gameView.build(box, building, true);
				switch (scenario){
					case Values.SCENARIO_HEAVEN:
						play(R.raw.heaventopia);
						break;
					case Values.SCENARIO_HELL:
						play(R.raw.helltopia);
						break;
				}
				gameView.box[box].setBeds(Values.TOPIA_3_BEDS);
				gameView.box[box].setConsumption(Values.TOPIA_3_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.TOPIA_3_WORKERS);
				gameView.box[box].setVibes(Values.TOPIA_3_VIBES);
				break;
			case Values.BUILDING_STATION_3:
				if (money < Values.STATION_3_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.STATION_3_PRICE;
				gameView.build(box, building, true);
				play(R.raw.station);
				gameView.box[box].setCars(Values.STATION_3_TICKETS);
				gameView.box[box].setConsumption(Values.STATION_3_CONSUMPTION);
				gameView.box[box].setWorkplaces(Values.STATION_3_WORKERS);
				gameView.box[box].setVibes(Values.STATION_3_VIBES);
				break;				
			case Values.BUILDING_SIPHON_3:
				if (money < Values.SIPHON_3_PRICE){
					Toast.makeText(getApplicationContext(), getString(R.string.msgNoMoney), Toast.LENGTH_SHORT).show();
					return;
				}
				money = money - Values.SIPHON_3_PRICE;
				gameView.build(box, building, true);
				play(R.raw.siphon);
				gameView.box[box].setProduction(Values.SIPHON_3_PRODUCTION);
				gameView.box[box].setWorkplaces(Values.SIPHON_3_PRODUCTION);
				gameView.box[box].setVibes(Values.SIPHON_3_VIBES);
				break;
			case Values.BUILDING_SPECIAL_3:
				gameView.build(box, building, true);
				gameView.box[box].setVibes(Values.SPECIAL_3_VIBES);
				break;
		}
	}
	
	//When destroying a building
	public void destroy(int box){
		gameView.destroy(box);
		gameView.box[box].setVibes(0);
		play(R.raw.destroy);
	}
	
	/*************************************************/
	/* Calculate vibes *******************************/
	/*************************************************/
	/* Loops for each box calculating vibrations *****/
	/* influence. A lot of special cases, hard to ****/
	/* explain here. *********************************/
	/*************************************************/
	public void calculateVibes(){
		//Reset all
		for (int i = 0; i < 144; i ++)
			gameView.box[i].setUnderVibes(0);
		//Calculate
		for (int i = 0; i < 144; i ++){
			//Itself
			gameView.box[i].addVibes(gameView.box[i].getVibes());
			//Directly adjacent boxes
			if (i != 143 && (i + 1) % 12 != 0)
				gameView.box[i + 1].addVibes(gameView.box[i].getVibes() / 2);
			if (i != 0 && i % 12 != 0)
				gameView.box[i - 1].addVibes(gameView.box[i].getVibes() / 2);
			if (i <= 131)
				gameView.box[i + 12].addVibes(gameView.box[i].getVibes() / 2);
			if (i >= 12)
				gameView.box[i - 12].addVibes(gameView.box[i].getVibes() / 2);
			//Diagonally adjacent boxes
			if (i <= 132 && i % 12 != 0)
				gameView.box[i + 11].addVibes(gameView.box[i].getVibes() / 3);
			if (i <= 30 && (i + 1) % 12 != 0)
				gameView.box[i + 13].addVibes(gameView.box[i].getVibes() / 3);
			if (i >= 11 && (i + 1) % 12 != 0)
				gameView.box[i - 11].addVibes(gameView.box[i].getVibes() / 3);
			if (i >= 13 && i % 12 != 0)
				gameView.box[i - 13].addVibes(gameView.box[i].getVibes() / 3);
			//Directly adjacent, one step further
			if (i <= 141 && (i + 2) % 12 != 0)
				gameView.box[i + 2].addVibes(gameView.box[i].getVibes() / 4);
			if (i >= 2 && (i - 2) % 12 != 0)
				gameView.box[i - 2].addVibes(gameView.box[i].getVibes() / 4);
			if (i <= 119)
				gameView.box[i + 24].addVibes(gameView.box[i].getVibes() / 4);
			if (i >= 24)
				gameView.box[i - 24].addVibes(gameView.box[i].getVibes() / 4);
		}
		
	}
	
	//Load preferences
	public void loadPreferences(){
		SharedPreferences settings = getSharedPreferences("settings", 0);
		prefMusic = settings.getBoolean("settings_music", true);
		prefFX = settings.getBoolean("settings_fx", true);
		prefFullScreen = settings.getBoolean("settings_fullscreen", false);
		prefKeepAwake = settings.getBoolean("settings_keepAwake", false);
	}
	
	//Load preferences
	public void loadCheats(){
		SharedPreferences settings = getSharedPreferences("cheats", 0);
		cheatX10 = settings.getBoolean("cheats_x10", true);
		cheatEarnings = settings.getBoolean("cheats_earnings", true);
		cheatDebt = settings.getBoolean("cheats_debt", false);
	}
	
	//Load game
	public void loadGame(){
		SharedPreferences savedGame = getSharedPreferences("SAVE_DEFAULT", 0);
		switch (scenario){
			case Values.SCENARIO_HEAVEN:
				savedGame = getSharedPreferences("SAVE_HEAVEN", 0);
				break;
			case Values.SCENARIO_HELL:
				savedGame = getSharedPreferences("SAVED_HELL", 0);
		}
		money = savedGame.getInt("money", Values.INITIAL_MONEY);
		year = savedGame.getInt("year", 0);
		souls = savedGame.getInt("souls", 0);
		workersLocal = savedGame.getInt("workers", 0);
		for(int i = 0; i < 144; i++){
			if (savedGame.getInt("box" + Integer.toString(i) + "Building", Values.BUILDING_NONE) != Values.BUILDING_NONE)
			gameView.build(i, savedGame.getInt("box" + Integer.toString(i) + "Building", Values.BUILDING_NONE), false);
				gameView.box[i].setAge(savedGame.getInt("box" + Integer.toString(i) + "Age", 0));
			gameView.box[i].setInputCapacity(savedGame.getInt("box" + Integer.toString(i) + "Input", 0));
			gameView.box[i].setCars(savedGame.getInt("box" + Integer.toString(i) + "Cars", 0));
			gameView.box[i].setBeds(savedGame.getInt("box" + Integer.toString(i) + "Beds", 0));
			gameView.box[i].setStudyplaces(savedGame.getInt("box" + Integer.toString(i) + "Studyplaces", 0));
			gameView.box[i].setWorkplaces(savedGame.getInt("box" + Integer.toString(i) + "Workplaces", 0));
			gameView.box[i].setConsumption(savedGame.getInt("box" + Integer.toString(i) + "Consumption", 0));
			gameView.box[i].setProduction(savedGame.getInt("box" + Integer.toString(i) + "Production", 0));
			gameView.box[i].setVibes(savedGame.getFloat("box" + Integer.toString(i) + "Vibes", 0));
			for(int j = 0; j < 7; j++)
				gameView.box[j].setHosting(j, savedGame.getInt("box" + Integer.toString(i) + "Hosting" + Integer.toString(j), 0));
		}
		newYear();
	}
	
	//Save the game
	public void saveGame(){
		SharedPreferences savedGame = getSharedPreferences("SAVE_DEFAULT", 0);
		switch (scenario){
			case Values.SCENARIO_HEAVEN:
				savedGame = getSharedPreferences("SAVE_HEAVEN", 0);
				break;
			case Values.SCENARIO_HELL:
				savedGame = getSharedPreferences("SAVE_HELL", 0);
		}
		SharedPreferences.Editor editor = savedGame.edit();
		editor.putInt("money", money);
		editor.putInt("year", year);
		editor.putInt("souls", souls);
		editor.putInt("workers", workersLocal);
		for(int i = 0; i < 144; i++){
			editor.putInt("box" + Integer.toString(i) + "Building", gameView.box[i].getBuilding());
			editor.putInt("box" + Integer.toString(i) + "Age", gameView.box[i].getAge());
			editor.putInt("box" + Integer.toString(i) + "Input", gameView.box[i].getInputCapacity());
			editor.putInt("box" + Integer.toString(i) + "Cars", gameView.box[i].getCars());
			editor.putInt("box" + Integer.toString(i) + "Beds", gameView.box[i].getBeds());
			editor.putInt("box" + Integer.toString(i) + "StudyPlaces", gameView.box[i].getStudyplaces());
			editor.putInt("box" + Integer.toString(i) + "WorkPlaces", gameView.box[i].getWorkplaces());
			editor.putInt("box" + Integer.toString(i) + "Consumption", gameView.box[i].getConsumption());
			editor.putInt("box" + Integer.toString(i) + "Production", gameView.box[i].getProduction());
			editor.putFloat("box" + Integer.toString(i) + "Vibes", (float) gameView.box[i].getVibes());
			for(int j = 0; j < 7; j++)
				editor.putInt("box" + Integer.toString(i) + "Hosting" + Integer.toString(j), gameView.box[i].getHosting(j));
		}
		editor.putInt("specialLevel", specialLevel);
		editor.putBoolean("savedGame", true);
		
		// Commit the edits!
		editor.commit();
    }
	
	/*************************************************/
	/* On finish activity ****************************/
	/*************************************************/
	/* Saves the game if it's running. Otherwise it **/
	/* deletes last saved game ***********************/
	/*************************************************/
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event){
		if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)
			finish();
	    return super.onKeyDown(keyCode, event);
	}
	
	@Override   
	public void onPause(){
		game = false;
		saveGame();
		android.os.Process.killProcess(android.os.Process.myPid());
		//TODO: Not sure if I ever reach this point, as well as the onDestroy() method
		gameView.clear();
		gameView = null;
		//super.onPause();
		finish();
	}
	
	public void onDestroy(){
		super.onDestroy();
		android.os.Process.killProcess(android.os.Process.myPid());
	}
	//Getters and setters
	public byte getScenario() {
		return scenario;
	}

	public void setScenario(byte scenario) {
		this.scenario = scenario;
	}
}
